/**
  ******************************************************************************
  * @file    iap_uart.h 
  * @author  iron
  * @date 	 2018-07-09
  * @version v1.0
  * @brief   iap_uart header file
  */

#ifndef __IAP_UART_H
#define __IAP_UART_H

#ifdef __cplusplus
 extern "C" {
#endif 

/* includes -------------------------------------------------------------------*/
#include <stdint.h>

/* exported define ------------------------------------------------------------*/
#define IAP_UART_DEFAULT_TIMEOUT	100
#define IAP_UART_GETC_TIMEOUT			10000

/* exported types ------------------------------------------------------------*/
typedef enum 
{
  IAP_UART_OK       = 0x00U,	// HAL_OK
  IAP_UART_ERROR    = 0x01U,	// HAL_ERROR
  IAP_UART_BUSY     = 0x02U,	// HAL_BUSY
  IAP_UART_TIMEOUT  = 0x03U		// HAL_TIMEOUT
} iap_uart_st;

/* exported constants --------------------------------------------------------*/
/* exported macro ------------------------------------------------------------*/
/* exported functions ------------------------------------------------------- */
int iap_uart_init(void);

int iap_uart_recv(uint8_t *p_data, uint32_t size, uint32_t timeout);
int iap_uart_send(uint8_t *p_data, uint32_t length, uint32_t timeout);

int iap_uart_getc(uint32_t timeout);
int iap_uart_putc(uint8_t chr);

void iap_uart_rx_flush(void);

void iap_uart_send_str(uint8_t *p_string);

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __IAP_UART_H */

/*******************(C)COPYRIGHT 2018 Iron *****END OF FILE*******************/
